#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

int mysys(char *command){
  if(command == NULL){
    return 1;
  }
  pid_t pid;
  int status;
  pid = fork();
  if(pid < 0){
    status = -1;
  }
  if(pid == 0){
    char *str = (char*)malloc(sizeof(command));
    strcpy(str,command);
    char* argv[16] = {NULL};
    int i = 0;
    argv[i] = strtok(str," ");
    while(argv[i] != NULL){
      i++;
      argv[i] = strtok(NULL," ");
    }
    int error = execvp(argv[0],argv);
    if(error <0){perror("execvp");}
    wait(NULL);
    exit(127);
  }
  return status;
}
int main()
{
    printf("--------------------------------------------------\n");
    mysys("echo HELLO WORLD");
    printf("--------------------------------------------------\n");
    mysys("ls /");
    printf("--------------------------------------------------\n");
    return 0;
}